package com.ruoyi.web.controller.fx;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.service.fx.IFxDistributionSettingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FxDistributionSetting;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分销比例设置Controller
 * 
 * @author ruoyi
 * @date 2024-09-12
 */
@RestController
@RequestMapping("/fx/system/setting")
public class FxDistributionSettingController extends BaseController
{
    @Autowired
    private IFxDistributionSettingService fxDistributionSettingService;

    /**
     * 查询分销比例设置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FxDistributionSetting fxDistributionSetting)
    {
        startPage();
        List<FxDistributionSetting> list = fxDistributionSettingService.selectFxDistributionSettingList(fxDistributionSetting);
        return getDataTable(list);
    }

    /**
     * 导出分销比例设置列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxDistributionSetting fxDistributionSetting)
    {
        List<FxDistributionSetting> list = fxDistributionSettingService.selectFxDistributionSettingList(fxDistributionSetting);
        ExcelUtil<FxDistributionSetting> util = new ExcelUtil<FxDistributionSetting>(FxDistributionSetting.class);
        util.exportExcel(response, list, "分销比例设置数据");
    }

    /**
     * 获取分销比例设置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxDistributionSettingService.selectFxDistributionSettingById(id));
    }

    /**
     * 新增分销比例设置
     */
    @PostMapping
    public AjaxResult add(@RequestBody FxDistributionSetting fxDistributionSetting)
    {
        return toAjax(fxDistributionSettingService.insertFxDistributionSetting(fxDistributionSetting));
    }

    /**
     * 修改分销比例设置
     */
    @PutMapping
    public AjaxResult edit(@RequestBody FxDistributionSetting fxDistributionSetting)
    {
        fxDistributionSettingService.updateFxDistributionSetting(fxDistributionSetting);
        return success();
    }

    /**
     * 删除分销比例设置
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxDistributionSettingService.deleteFxDistributionSettingByIds(ids));
    }
}
